#include<bits/stdc++.h>
using namespace std;
#define int long long

int mp['Z' + 5];

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	char x, y, z;
	cin >> x >> y >> z;

	mp['A'] = min(a, min(b, c));
	mp['C'] = max(a, max(b, c));
	mp['B'] = a + b + c - mp['A'] - mp['C'];
	cout << mp[x] << " " << mp[y] << " " << mp[z];
	return 0;
}
